import os
import secrets

from redis import Redis


class FlaskSettings:
    # Flask原生配置
    DEBUG = False
    SECRET_KEY = secrets.token_hex(256)
    SESSION_COOKIE_HTTPONLY = True
    MAX_CONTENT_LENGTH = 1024 * 1024 * 1024 * 1024
    MAX_COOKIE_SIZE = 4096
    PERMANENT_SESSION_LIFETIME = 24 * 60 * 60
    SESSION_REFRESH_EACH_REQUEST = True
    # Flask-Session配置
    SESSION_PERMANENT = True
    SESSION_TYPE = 'redis'
    SESSION_REDIS = Redis.from_url('redis://redis:6379')

    # 文件上传路径
    UPLOAD_FOLDER = '/opt/media'
    UPLOAD_PREFIX = '/api/resource/'

    # jwt 相关配置
    JWT_SECRET_KEY = 'example'
    JWT_COOKIE_CSRF_PROTECT = True
    JWT_CSRF_CHECK_FORM = True
    JWT_ACCESS_TOKEN_EXPIRES = 24 * 60 * 60
    PROPAGATE_EXCEPTIONS = True
    JWT_TOKEN_LOCATION = ["headers", "cookies", "json", "query_string"]


if __name__ == '__main__':
    print(FlaskSettings.SECRET_KEY)
